<?php

	session_start();
	if($_SESSION["username"] == "")
	{
		header("location:login.php");
		exit();
	}

	include 'connectDB.php';

	$strSQL = "SELECT * FROM tbl_user WHERE username = '".$_SESSION["username"]."'  ";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$objResult = mysql_fetch_array($objQuery);
?>
<html>
<head>
	<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
	<div id="header">
		<p >Edit Item Page.</p>
	</div>
	<div id="container">	
		<a href="dashboard.php">dashboard</a> > <a href="Item.php">item</a> > <a href="">Edit item</a>
		<br>	
		<br>
	<?php
		include 'connectDB.php';
		$strSQL = "SELECT * FROM tbl_item WHERE item_id = '".$_GET[ItemID]."' ";
		$objQuery  = mysql_query($strSQL);
		$objResult = mysql_fetch_array($objQuery);
		if(!$objResult)
		{
			echo "Not found item_id =".$_GET["ItemID"];
		}
		else
		{
	?>
		<form name="frmEditItem" action="EditItemSave.php?ItemID=<?=$_GET["ItemID"];?>" method="post">
		<table border="0 " cellpadding="10" cellspacing="0" style="margin-left: 50px;">
			<tr>
				<td>Item ID :</td>
				<td><input type="text" name="txtItemID" style="padding: 10px;" disabled="" value="<?php echo $objResult[item_id];?>"/></td>
			</tr>
			<tr>
				<td>Item Name :</td>
				<td><input type="text" name="txtItemName" style="padding: 10px;" value="<?php echo $objResult[item_name];?>"/></td>
			</tr>
			<tr>
				<td>Price :</td>
				<td><input type="text" name="txtPrice" style="padding: 10px;" value="<?php echo $objResult[price];?>"/></td>
			</tr>
	<?php
		}
	?>	
			<tr>
				<td>Merchant Name:</td>
			<?php
  				$strSQL = "SELECT * FROM tbl_merchant ";
  				$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
			?>
				<td><select name="Merchant">
			<?php
			 while ($objResult = mysql_fetch_array($objQuery)) 
			 {
			?> 
						<option value="<?php echo $objResult[mer_id];?>"><?php echo $objResult[mer_name];?></option>
			<?php
 			 }
			?>
				</select></td>
			</tr>
			
			<tr>
				<td></td>
				<td><input type="submit" name="submit" value="submit" style="padding: 10px;"> <input type="reset" name="reset" value="reset" style="padding: 10px;"/></td>
			</tr>		
		</table>
		</form>
	</div>
</body>
</html>